package org.dreamwork.jasmine2.web.client;

import java.util.regex.Matcher;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 12-4-25
 * Time: 下午6:13
 */
public class FireFoxParser {
/*
Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0
group[1]=20100101
group[2]=11.0

Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.12) Gecko/2009072711 CentOS/3.0.12-1.el5.centos Firefox/3.0.12
group[1]=2009072711
group[2]=3.0.12

Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0
group[1]=20100101
group[2]=8.0

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
group[1]=20101203
group[2]=3.6.13
     */
    public static UserAgent parse (Matcher m) {
        UserAgent agent = new UserAgent (m.group (0));
        agent.setType (BrowserType.FireFox);
        Version version = new Version (m.group (1));
        RenderKernel kernel = new RenderKernel (RenderkernelType.Gecko, version);
        agent.setKernel (kernel);

        OperationSystem os = OSParser.parseOS (m.group (0));
        agent.setOs (os);

        Architecture arch = os.getArchitecture ();
        agent.setDevice (DeviceTypeUtil.getDeviceType (arch));

        version = new Version (m.group (2));
        agent.setVersion (version);
        return agent;
    }
}